import { createRouter, createWebHistory } from 'vue-router'
// import login from '@/views/login/index.vue'
import Layout from '@/views/layout/Index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: Layout,
      children:[
        {
          path: '/',
          name:'home',
          component:()=>import('../views/home/Index.vue'),
        },
        {
          path: '/product',
          name:'product',
          component:()=>import('../views/product/Index.vue'),
          children:[
            {
              path: '/product/category',
              name:'category',
              component:()=>import('../views/product/Category.vue')
            },
            {
              path: '/product/list',
              name:'productlist',
              component:()=>import('../views/product/List.vue')
            }
          ]
        },
        {
          path: '/order',
          name:'order',
          component:()=>import('../views/order/Index.vue'),
          children:[
            {
              path: '/order/list',
              name:'orderlist',
              component:()=>import('../views/order/List.vue')
            },
            {
              path: '/order/collect',
              name:'collect',
              component:()=>import('../views/order/Collect.vue')
            }
          ]
        },
        {
          path: '/advert',
          name:'advert',
          component:()=>import('../views/advert/Index.vue'),
          children:[
            {
              path: '/advert/list',
              name:'advertlist',
              component:()=>import('../views/advert/List.vue')
            }
          ]
        }
        
      ]
    },
    {
      path: '/login',
      name: 'login',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      // component: () => import('../views/AboutView.vue')
      component:()=>import('../views/login/Index.vue')
    }
  ]
})

// 设置前置路由守卫
router.beforeEach((to, from, next) => {
  next()
})

// 设置后置路由守卫
router.afterEach((to, from, failure) => {
   
})

export default router
